Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django login and logout functionality #276

Merged
merged 26 commits into from
Dec 29, 2024

Conversation

Archmonger
Copy link
Contributor

@Archmonger Archmonger commented Dec 23, 2024

Description

This PR contains any hooks and settings needed to make user authentication in Django easy.

This PR exists because Django's requires cookies to retain login status. ReactPy is rendered via WebSockets, and browsers do not allow active WebSocket connections to create/modify cookies.

To work around this limitation, when reactpy_django.hooks.use_auth().login() is called within your application, ReactPy will automatically create a login token and command the browser to fetch it at our new HTTP endpoint.

Changelog

  • User login/logout features!
    • reactpy_django.hooks.use_auth to provide persistent login and logout functionality to your components.
    • settings.py:REACTPY_AUTH_TOKEN_TIMEOUT to control the maximum seconds before ReactPy no longer allows the browser to obtain a persistent login cookie.
    • settings.py:REACTPY_CLEAN_AUTH_TOKENS to control whether ReactPy should clean up expired authentication tokens during automatic cleanups.
  • The ReactPy component tree can now be forcibly re-rendered via the new reactpy_django.hooks.use_rerender hook.

Checklist

Please update this checklist as you complete each item:

  • Tests have been developed for bug fixes or new functionality.
  • The changelog has been updated, if necessary.
  • Documentation has been updated, if necessary.
  • GitHub Issues closed by this PR have been linked.

By submitting this pull request I agree that all contributions comply with this project's open source license(s).

@Archmonger Archmonger marked this pull request as ready for review December 29, 2024 10:25
@Archmonger Archmonger requested a review from a team as a code owner December 29, 2024 10:25
@Archmonger Archmonger merged commit b9af25d into reactive-python:main Dec 29, 2024
15 checks passed
@Archmonger Archmonger deleted the login-functionality branch December 29, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

login / logout functions
1 participant